<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 100px;
            height: 100px;
            background-color: pink;
        }
        .boxx{
            width: 100px;
            height: 100px;
            background-color: blue;
        }
    </style>
</head>
<body>
    <button id="btn">点击</button>
    <div class="box"></div>
    <div class="boxx"></div>
    <script>
        // 1 获取相应的元素
        var btn = document.getElementById("btn")
        // 2 绑定事件
    btn.onclick = function(){
        // 3 执行代码
        alert("你点我干嘛")
    }
    // 1 获取相应的元素
    var box = document.querySelector(".box")
    // 2 绑定事件 鼠标移入事件
    box.onmouseover = function(){
        // box.style.backgroundColor = "red"
        // 鼠标移入显示
        boxx.style.display = "block"
    }
    box.onmouseover = function(){
        // box.style.backgroundColor = "pink"
        // 鼠标移出隐藏
        boxx.style.display = "none"
    }
    </script>
</body>
</html>